package com.ruoyi.contract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contract.domain.ArchiveLocation;
import com.ruoyi.contract.service.IArchiveLocationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 原文件归档位置Controller
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/contract/ArchiveLocation")
public class ArchiveLocationController extends BaseController
{
    @Autowired
    private IArchiveLocationService archiveLocationService;

    /**
     * 查询原文件归档位置列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ArchiveLocation:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveLocation archiveLocation)
    {
        startPage();
        List<ArchiveLocation> list = archiveLocationService.selectArchiveLocationList(archiveLocation);
        return getDataTable(list);
    }

    /**
     * 导出原文件归档位置列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ArchiveLocation:export')")
    @Log(title = "原文件归档位置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveLocation archiveLocation)
    {
        List<ArchiveLocation> list = archiveLocationService.selectArchiveLocationList(archiveLocation);
        ExcelUtil<ArchiveLocation> util = new ExcelUtil<ArchiveLocation>(ArchiveLocation.class);
        util.exportExcel(response, list, "原文件归档位置数据");
    }

    /**
     * 获取原文件归档位置详细信息
     */
    @PreAuthorize("@ss.hasPermi('contract:ArchiveLocation:query')")
    @GetMapping(value = "/{archiveLocationId}")
    public AjaxResult getInfo(@PathVariable("archiveLocationId") Long archiveLocationId)
    {
        return success(archiveLocationService.selectArchiveLocationByArchiveLocationId(archiveLocationId));
    }

    /**
     * 新增原文件归档位置
     */
    @PreAuthorize("@ss.hasPermi('contract:ArchiveLocation:add')")
    @Log(title = "原文件归档位置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveLocation archiveLocation)
    {
        return toAjax(archiveLocationService.insertArchiveLocation(archiveLocation));
    }

    /**
     * 修改原文件归档位置
     */
    @PreAuthorize("@ss.hasPermi('contract:ArchiveLocation:edit')")
    @Log(title = "原文件归档位置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveLocation archiveLocation)
    {
        return toAjax(archiveLocationService.updateArchiveLocation(archiveLocation));
    }

    /**
     * 删除原文件归档位置
     */
    @PreAuthorize("@ss.hasPermi('contract:ArchiveLocation:remove')")
    @Log(title = "原文件归档位置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{archiveLocationIds}")
    public AjaxResult remove(@PathVariable Long[] archiveLocationIds)
    {
        return toAjax(archiveLocationService.deleteArchiveLocationByArchiveLocationIds(archiveLocationIds));
    }
}
